package com.yuantu.judiciary.model;

import com.yuantu.judiciary.config.DataBaseAuditListener;
import lombok.Data;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * 数据库基础类
 *
 * @author syw
 * @since 2023-06-07
 */
@Data
@MappedSuperclass
@EntityListeners(DataBaseAuditListener.class)
public abstract class BaseDO implements Serializable {

    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(columnDefinition = "datetime")
    private Timestamp createTime;

    /**
     * 修改时间
     */
    @LastModifiedDate
    @Column(columnDefinition = "datetime")
    private Timestamp modifyTime;

    /**
     * 创建人ID
     */
    @CreatedBy
    private Long creatorId;

    /**
     * 修改人ID
     */
    @LastModifiedBy
    private Long modifierId;

    /**
     * 是否失效
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean deleted = Boolean.FALSE;


}
